package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Detectresult;
import com.ruoyi.system.service.IDetectresultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检测报告Controller
 * 
 * @author gzhuangwei
 * @date 2022-09-17
 */
@RestController
@RequestMapping("/business/detectresult")
public class DetectresultController extends BaseController
{
    @Autowired
    private IDetectresultService detectresultService;

    /**
     * 查询检测报告列表
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:list')")
    @GetMapping("/list")
    public TableDataInfo list(Detectresult detectresult)
    {
        startPage();
        List<Detectresult> list = detectresultService.selectDetectresultList(detectresult);
        return getDataTable(list);
    }

    /**
     * 导出检测报告列表
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:export')")
    @Log(title = "检测报告", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Detectresult detectresult)
    {
        List<Detectresult> list = detectresultService.selectDetectresultList(detectresult);
        ExcelUtil<Detectresult> util = new ExcelUtil<Detectresult>(Detectresult.class);
        util.exportExcel(response, list, "检测报告数据");
    }

    /**
     * 获取检测报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(detectresultService.selectDetectresultById(id));
    }

    /**
     * 新增检测报告
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:add')")
    @Log(title = "检测报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Detectresult detectresult)
    {
        return toAjax(detectresultService.insertDetectresult(detectresult));
    }

    /**
     * 修改检测报告
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:edit')")
    @Log(title = "检测报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Detectresult detectresult)
    {
        return toAjax(detectresultService.updateDetectresult(detectresult));
    }

    /**
     * 删除检测报告
     */
    @PreAuthorize("@ss.hasPermi('business:detectresult:remove')")
    @Log(title = "检测报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(detectresultService.deleteDetectresultByIds(ids));
    }
}
